# $Id$
# Maintainer: Allan McRae <allan@archlinux.org>

pkgname=('cloog' 'cloog-devel')
pkgver=0.18.3
pkgrel=1
groups=('libraries')
pkgdesc="Library that generates loops for scanning polyhedra"
arch=('i686' 'x86_64')
url="http://www.bastoul.net/cloog/"
license=('GPL')
depends=('isl')
makedepends=('isl-devel')
source=(http://www.bastoul.net/cloog/pages/download/${pkgname}-${pkgver}.tar.gz
        cloog-0.18.0-msys2.patch
        cloog-0.18.3-no-undefined.patch)
md5sums=('3ded42bb87022981abccd42466a00b65'
         'b5c5e19bb58447f4e87a328e82aa17fa'
         '8c8c63a1060e02ed4c96b8d571f852cc')

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  patch -p1 -i ${srcdir}/cloog-0.18.0-msys2.patch
  patch -p1 -i ${srcdir}/cloog-0.18.3-no-undefined.patch

  WANT_AUTOMAKE=latest autoreconf -fiv
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  ./configure \
      --prefix=/usr \
      --enable-shared \
      --disable-static \
      --with-isl=system \
      --with-bits=gmp \
      --program-suffix=-isl
  make
  make DESTDIR=${srcdir}/dest install
}

check() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make check
}

package_cloog() {
  mkdir -p ${pkgdir}/usr/bin
  cp -f ${srcdir}/dest/usr/bin/*.dll ${pkgdir}/usr/bin
}

package_cloog-devel() {
  pkgdesc="CLOOG headers and libraries"
  groups=('development')
  depends=("cloog=${pkgver}" 'isl-devel')

  mkdir -p ${pkgdir}/usr

  cp -rf ${srcdir}/dest/usr/include ${pkgdir}/usr/
  cp -rf ${srcdir}/dest/usr/lib ${pkgdir}/usr/
}
